home *** CD-ROM | disk | FTP | other *** search
/ CDV Software Presents (USA) / CDV Software Presents (USA).bin / demo / bk_demo.exe / DATA.PAK / ui / common / campainselect.lua < prev    next >
Encoding:
Text File  |  2002-12-05  |  1.1 KB  |  42 lines

  1. nNumberOfButtons = 0
  2. nActiveButton = 0
  3. bInit = 0
  4.  
  5. --the variable nNumberOfButtons is initilized from GlobalVar
  6. --so that we do not need to write explicit LUA serialize code to save it
  7. --when chapter or campaign screen is loading, the game serialize all GlobalVars
  8. --and script is initializing after all global variables are loaded
  9.  
  10. function ClearState( nControl )
  11.     i = 1000
  12.     while ( i <= 1000 + nNumberOfButtons ) do
  13.         if ( i ~= nControl ) then
  14.             AddMessage( 65538, i, 0 )        --UI_SET_STATE_WO_NOTIFY to  0 (clear state)
  15.         end
  16.         i = i + 1
  17.     end
  18. end
  19.  
  20. function LuaProcessMessage( nMessageCode, nFirst, nSecond )
  21.     if ( bInit == 0 ) then
  22.         nNumberOfButtons = InitCommonScript()
  23.         bInit = 1
  24.     end
  25.  
  26.     if ( nMessageCode == 536936448 and ( nFirst >= 1000 and nFirst <= 1000+nNumberOfButtons  ) ) then -- chapter button pressed
  27.         if ( nSecond == 0 ) then
  28.             AddMessage( 65536, nFirst, 1 )    --SET_STATE back to 1 (cannot deselect)
  29.             return 1
  30.         end
  31.         
  32.         if ( nSecond  == 1 ) then
  33.             local nMessage = SetProcessedFlag( nFirst )
  34.             AddMessage( nMessage, 0, 1 )
  35.             ClearState( nFirst )
  36.             return 1;
  37.         end
  38.  
  39.         return 1
  40.     end
  41. end
  42.